﻿<UserControl  
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    xmlns:commands="clr-namespace:Microsoft.Practices.Composite.Presentation.Commands;assembly=Microsoft.Practices.Composite.Presentation" 
    x:Class="VisualStock.Modules.StockSymbols.ComparingSymbols.ComparingSymbolListView"
    mc:Ignorable="d"
	d:DesignHeight="300">
    <UserControl.Resources>
        <DataTemplate x:Key="ComparingSymbolListBox">
            <Grid>
                <Button Template="{StaticResource ComparingSymbolButtonStyle}" Foreground="White" Background="Transparent"/>
            </Grid>
        </DataTemplate>
        <Style x:Key="DownloadListBoxItemStyle" TargetType="ListBoxItem">
        	<Setter Property="Template">
        		<Setter.Value>
        			<ControlTemplate TargetType="ListBoxItem">
        				<Grid Height="20">
        					<Grid.ColumnDefinitions>
        						<ColumnDefinition Width="Auto"/>
        						<ColumnDefinition/>
        					</Grid.ColumnDefinitions>
        					<VisualStateManager.VisualStateGroups>
        						<VisualStateGroup x:Name="CommonStates">
        							<VisualState x:Name="Normal"/>
        							<VisualState x:Name="MouseOver"/>
        							<VisualState x:Name="Disabled"/>
        						</VisualStateGroup>
        						<VisualStateGroup x:Name="FocusStates">
        							<VisualState x:Name="Unfocused"/>
        							<VisualState x:Name="Focused"/>
        						</VisualStateGroup>
        						<VisualStateGroup x:Name="SelectionStates">
        							<VisualState x:Name="Unselected"/>
        							<VisualState x:Name="Selected"/>
        							<VisualState x:Name="SelectedUnfocused"/>
        						</VisualStateGroup>
        					</VisualStateManager.VisualStateGroups>
        					<TextBlock Text="{Binding Symbol}" VerticalAlignment="Center"/>
        					<ProgressBar d:LayoutOverrides="Height" Grid.Column="1" IsIndeterminate="True"/>
        					<TextBlock Text="{Binding DownloadStatus}" Grid.Column="1" VerticalAlignment="Center" HorizontalAlignment="Center"/>
        				</Grid>
        			</ControlTemplate>
        		</Setter.Value>
        	</Setter>
        </Style>
    </UserControl.Resources>

    <Grid x:Name="LayoutRoot" Width="200">
    	<Grid.Effect>
    		<DropShadowEffect/>
    	</Grid.Effect>
    	<Rectangle x:Name="BackgroundFill" RadiusX="5" RadiusY="5" Grid.RowSpan="3" Stroke="#FFCDCDCD">
    		<Rectangle.Fill>
    			<SolidColorBrush Color="#FFB9A266"/>
    		</Rectangle.Fill>
    	</Rectangle>

    	<Grid Margin="5">
    		<Grid.RowDefinitions>
    			<RowDefinition Height="Auto"/>
    			<RowDefinition Height="Auto"/>
    			<RowDefinition/>
    			<RowDefinition Height="Auto"/>
    		</Grid.RowDefinitions>
			
    		<ListBox ItemContainerStyle="{StaticResource DownloadListBoxItemStyle}" ItemsSource="{Binding DownloadList}"/>
    		<Grid x:Name="SymbolTextBar" Grid.Row="1">
    			<Grid.ColumnDefinitions>
    				<ColumnDefinition/>
    				<ColumnDefinition Width="Auto" MinWidth="15"/>
    			</Grid.ColumnDefinitions>
    			<TextBox x:Name="NewSymbolTxb" Style="{StaticResource AddSymbolTextBoxStyle}"/>
    			<Button Content="AddSymbol" commands:Click.Command="{Binding AddCommand}" commands:Click.CommandParameter="{Binding Text, ElementName=NewSymbolTxb}" Grid.Column="1" Style="{StaticResource AddSymbolButtonStyle}" Width="25" Height="25" Cursor="Hand" Background="{x:Null}"/>
    		</Grid>
    		<ListBox x:Name="SymbolList" ItemsSource="{Binding ComparingSymbolList}" Background="Transparent" BorderThickness="0" ItemContainerStyle="{StaticResource ComparingSymbolListBoxItemStyle}" ToolTipService.ToolTip="Use CTRL key or SHIFT key to select multiple symbols" Grid.Row="2" SelectionChanged="ListBox_SelectionChanged" SelectionMode="Extended"/>
    		<StackPanel x:Name="Buttons" Orientation="Horizontal" d:LayoutOverrides="GridBox" Grid.Row="3">
    			<Button x:Name="CompareBtn" commands:Click.Command="{Binding CompareCommand}" ToolTipService.ToolTip="Only the first 5 symbols will be displayed" Style="{StaticResource SymbolOperationButtonStyle}" Content="Compare"/>
    			<Button x:Name="RemoveBtn" commands:Click.Command="{Binding RemoveCommand}" Content="Remove" Style="{StaticResource SymbolOperationButtonStyle}" ToolTipService.ToolTip="The selected symbol(s) will be deleted"/>
    		</StackPanel>
    	</Grid>
    </Grid>

</UserControl>
